package user.impl;


import exception.LoginErrorException;
import http.util.ArrayUtil;
import okhttp3.Cookie;
import org.apache.http.MethodNotSupportedException;
import user.AbstractUser;
import user.IUser;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Random;

/**
 * 简单用户数据传输类
 * 用来存放姓名 登录账号 登录密码 学生姓名
 *
 * @class AbstarctRobUser extend
 */
public class SimpleUserDTO extends AbstractUser implements IUser {

    private String username;
    private String password;
    private String studentName;
    private ArrayList<String> cookies = new ArrayList<String>();

    /**
     * 个人信息
     */
    @Override
    public void login() throws LoginErrorException {
        try {
            throw new MethodNotSupportedException("SimpleUserDTO 不支持 login()");
        } catch (MethodNotSupportedException e) {
            e.printStackTrace();
        }
    }

    @Override
    public String getUsername() {
        return username;
    }

    @Override
    public void setUsername(String username) {
        this.username = username;
    }

    @Override
    public String getPassword() {
        return password;
    }

    @Override
    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    public String getStudentName() {
        return studentName;
    }

    @Override
    public void setStudentName(String studentName) {
        this.studentName = studentName;
    }

    @Override
    public ArrayList<String> getCookies() {
        return this.cookies;
    }

    @Override
    public void setCookies(ArrayList<String> cookies) {
        this.cookies = cookies;
    }

    @Override
    public String getRandomCookie() {
//        System.out.println("目前可用getCookies() : " + getCookies());
        return ArrayUtil.getRandomDataFromArrayList(getCookies());
    }

    @Override
    public String toString() {
        return "SimpleUserDTO{" +
                "username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", studentName='" + studentName + '\'' +
                ", cookies=" + cookies +
                "} " + super.toString();
    }
}
